import { Component, OnInit } from '@angular/core';
import { HeroService } from '../../../services/hero.service';
import { StorageService } from '../../../services/storage.service';
import { NzModalService } from 'ng-zorro-antd';

@Component({
  selector: 'app-printertask',
  templateUrl: './printertask.component.html',
  styleUrls: ['./printertask.component.css']
})
export class PrintertaskComponent implements OnInit {

  loading = true;
  btn_loading=false;
  public number:string='';
  public printName:string='';
  public type:string='';
  public status:string='';
  public userinfo:string;
  public maintinfo:string;
  public isVisible:boolean;
  public patchcode:number;
  public patchValue:number;
  public tasklist:Array<any>=[];
  public PageIndex:number=1;
  public PageSize:number=10;
  public PageTotal:number;
  constructor(private heroService: HeroService,
              private modalService: NzModalService,
              private storageService: StorageService) { }

  ngOnInit() {
    this.getTasklist();
  }

  //获取任务工单列表数据
  getTasklist(){
    this.btn_loading=true;
    let url=host+"/main/merchantTaskInfo/list";
    let model="numberLike="+this.number+"&printerNameLike="+this.printName+"&type="+this.type+"&status="+this.status+"&page="+this.PageIndex+"&pageSize="+this.PageSize;
    this.heroService.post(url,model).then(result=>{
      this.btn_loading=false;
      if(result.code==0){
        this.tasklist=result.data.pageBean.result;
        this.userinfo=result.data.connectUser;
        this.maintinfo=result.data.connectMaint;
        this.PageIndex=result.data.pageBean.curPage;  
        this.PageTotal=result.data.pageBean.totalRow;
        this.loading=false;
      }else{
        this.modalService.error({
          nzTitle: '提示',
          nzContent: result.msg
        });
      }
    })
  }
  
  //分页
  PageIndexChange(event){
    this.PageIndex=event;
    this.getTasklist();
  }

  //导出Excel
  exportOut() {
    const token = this.storageService.getItem("token");
    window.location.href = host + "/main/merchantTaskInfo/excelExport?token="+token+"&numberLike="+this.number+"&printerNameLike="+this.printName+"&type="+this.type+"&status="+this.status;
  }
}
